package com.xc.controller.backend;

import com.xc.common.ServerResponse;
import com.xc.pojo.SitePay;
import com.xc.service.ISitePayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/3/15 8:06 PM
 */
@Controller
@RequestMapping("/admin/pay/")
@Slf4j
public class AdminSitePayController {

    @Autowired
    ISitePayService iSitePayService;

    /**
     *  添加支付渠道
     *  is_show  0 显示 1 不显示
     *  is_lock  0 不锁定 1 锁定
     * @param sitePay
     * @return
     */
    @RequestMapping("add.do")
    @ResponseBody
    public ServerResponse add(SitePay sitePay){
        return iSitePayService.add(sitePay);
    }


    /**
     *  修改支付渠道
     * @param sitePay
     * @return
     */
    @RequestMapping("update.do")
    @ResponseBody
    public ServerResponse update(SitePay sitePay){
        return iSitePayService.update(sitePay);
    }

    /**
     *  支付渠道列表
     * @param channelType
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(@RequestParam("channelType") String channelType
            ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
        ){
        return iSitePayService.listByAdmin(channelType,pageNum,pageSize);
    }


    @RequestMapping("del.do")
    @ResponseBody
    public ServerResponse del(@RequestParam("cId") Integer cId){
        return iSitePayService.del(cId);
    }




}



